

// Action 就是 View 发出的通知，表示 State 应该要发生变化了
// Action 是一个对象。其中的type属性是必须的  payload 

// 改变 State 的唯一办法，就是使用 Action。它会运送数据到 Store
// store.dispatch()是 View 发出 Action 的唯一方法 

export const descAction   = {
   type:"DESCACTION"
}

// action  creator

export function  changeCount(payload){
   return {
     type:'changeCount',
     payload
   }

  //  return action 
}

export function changeCity(payload){
  return {
    type:"changeCity",
    payload
  }
}

export function changeMsg(payload){
  return {
    type:"changeMsg",
    payload
  }
}

export const changeWord = payload=>{
  return {
    type:"changeWord",
    payload
  }
}


export const changeDataTxt = payload=>{
  return {
    type:"changeDataTxt",
    payload
  }
}



export const changeDataFlag = payload=>{
  return {
    type:"changeDataFlag",
    payload
  }
}

import {ajax} from "@/utils/request"


// export function changeDataTextAsync(){
//     return ajax.get("http://localhost:4400/api/test")
//     .then(res=>{
//        return {
//          type:"changeDataTextAsync",
//          payload:res.data.result 
//        }
//     })
// }


// export function changeDataMovieAsync(){
//   return ajax.get("http://localhost:4400/movie")
//   .then(res=>{
//      return {
//        type:"changeDataMovieAsync",
//        payload:res.data.result 
//      }
//   })
// }

export async function changeDataTextAsync(){
  let res = await  ajax.get("http://localhost:4400/api/test")
  return {
    type:"changeDataTextAsync",
    payload:res.data.result 
  }
}



export async function changeDataMovieAsync(){
   let res = await  ajax.get("http://localhost:4400/movie")
   return {
     type:"changeDataMovieAsync",
     payload:res.data.result 
   }
}


